package cn.shyouchi.wuguanjia.android.ui.home.security.thread.message.birthday;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.shyouchi.wuguanjia.android.Global;
import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.widget.GlideCircleTransform;

/**
 * Created by Eenie on 2017/3/17 at 16:39
 * Email: 472279981@qq.com
 * Des:
 */

public class BirthdayWishAdapter extends BaseQuickAdapter<BirthdayWish, BaseViewHolder> {
    public BirthdayWishAdapter(List<BirthdayWish> data) {
        super(R.layout.item_birthday_wish_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, BirthdayWish birthdayWish) {

        BirthdayGift birthdayGift = getGiftById(birthdayWish.getCake());

        holder.setText(R.id.tv_person_name, birthdayWish.getName());
        holder.setText(R.id.tv_gift_name, birthdayGift.getName());
        holder.setText(R.id.tv_wish, birthdayWish.getGreetings());
        loadHead(Global.BASE_URL + birthdayWish.getAvatar(), (ImageView) holder.getView(R.id.img_header));
        loadGift(birthdayGift.getIcon(), (ImageView) holder.getView(R.id.img_gift));
    }


    private BirthdayGift getGiftById(int id) {

        BirthdayGift birthdayGift = null;
        switch (id) {

            case 4001:
                birthdayGift = new BirthdayGift(4001, R.mipmap.ic_gift_case1, "巧克力蛋糕");

                break;
            case 4002:
                birthdayGift = new BirthdayGift(4002, R.mipmap.ic_gift_case2, "草莓蛋糕");

                break;
            case 4003:
                birthdayGift = new BirthdayGift(4003, R.mipmap.ic_gift_case3, "奶油蛋糕");
                break;

            default:
                birthdayGift = new BirthdayGift(4001, R.mipmap.ic_gift_case1, "巧克力蛋糕");
                break;

        }
        return birthdayGift;
    }

    private void loadHead(String path, ImageView imageView) {
        Glide.with(mContext)
                .load(path)
                .transform(new GlideCircleTransform(mContext))
                .into(imageView);
    }
    private void loadGift(int path, ImageView imageView) {
        Glide.with(mContext)
                .load(path)
                .into(imageView);
    }



}
